import time

from selenium import webdriver

driver=webdriver.Chrome()
# driver=webdriver.Firefox()
driver.get("file:///F:\\bcbx视频\\testAlert.html")
time.sleep(5)
driver.execute_script("prom()")
driver.switch_to.alert.send_keys("梁思德")
time.sleep(3)
print(driver.switch_to.alert.text)

driver.switch_to.alert.accept()
print(driver.switch_to.alert.text)
time.sleep(4)
driver.switch_to.alert.accept()#默认点击同意
driver.switch_to.alert.dismiss()#默认点击取消的意思

time.sleep(5)
driver.quit()


